package com.tx.vuemybatisplusajax.controller;/*
 *
 * @author 陈粒
 * @version 创建时间：2021/8/28 15:45
 */

import com.tx.vuemybatisplusajax.pojo.User;
import com.tx.vuemybatisplusajax.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;

    //通过id进行更新
    @PutMapping("setDefaultDamageBonus")
    public String setDefaultDamageBonus(){
        userService.setDefaultDamageBonus();
        return "修改成功";
    }

    //通过id进行更新
    @PutMapping("saveAll")
    public String saveAll(@RequestBody List<User> userList){
        userList.forEach(a-> userService.updatebyid(a));
        return "修改成功";
    }
    //查询所有数据
    @GetMapping("findall")
    public List<User> findall() {
        return userService.findall();
    }

    //分组
    @GetMapping("groupUsers")
    public List<List<User>> groupUsers() {
        return userService.groupUsers();
    }

    //分组
    @GetMapping("groupUsers2")
    public List<List<User>> groupUsers2() {
        return userService.groupUsers2();
    }


    //查询所有数据
    @GetMapping("getUser")
    public User getUser(@RequestParam("nickName") String nickName) {
        return userService.getUser(nickName);
    }

}
